#pragma once
#include "Link.h"

class Context_model
{
	int size_model;
	Link *first_link;
	Context_model *pred_model;
public:
	Context_model (int length, Context_model *prev = NULL, int *context = NULL, Link *pred = NULL);
	Link * Encode_sym (int sym, int *context);
	Link * Decode (int *context);
	void SingleLeftRotate (Link* &cur);
	void DoubleLeftRotate (Link* &cur);
	void SingleRightRotate (Link* &cur);
	void DoubleRightRotate (Link* &cur);
	void UpdateLeftTree (Link* &cur, int &changedbalance);
	void UpdateRightTree (Link* &cur, int &changedbalance);
	void Insert (Link* &root, Link *cur, int &changed);
	Link * Update (int sym, int *context, Link *match);
	Context_model * GetNext ();
	int GetSize ();
	~Context_model();
};